package com.aptemo.webetek.client.widgets.players;

import java.util.MissingResourceException;

import com.aptemo.webetek.client.Webetek;
import com.aptemo.webetek.client.widgets.CurrencyWidget;
import com.aptemo.webetek.shared.UserBean;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;

public class PlayerRow
		extends Composite
{

	private static PlayerRowUiBinder	uiBinder	= GWT.create(PlayerRowUiBinder.class);

	interface PlayerRowUiBinder extends UiBinder<Widget, PlayerRow>
	{
	}

	// @UiField
	// Label infoField;

	@UiField
	Label					emailField;

	@UiField
	Label					statusField;

	@UiField
	Label					roleField;

	@UiField
	CurrencyWidget			balanceField;

	// @UiField
	// Button approveButton;
	//
	// @UiField
	// Button rejectButton;

	private HandlerManager	eventbus;

	public PlayerRow(UserBean player)
	{
		initWidget(uiBinder.createAndBindUi(this));

		emailField.setText(player.getEmail());
		roleField.setText(translate(player.getRole().toString()));
		statusField.setText(translate(player.getStatus().toString()));

		balanceField.setValue(player.getBalance());
	}

	private String translate(String key)
	{
		try
		{
			return Webetek.getConstants().getString(key);
		}
		catch (MissingResourceException e)
		{
			return key;
		}
	}

}
